package com.station.client.dragNDrop;

import com.google.gwt.user.client.ui.Image;
import com.station.client.Base;
import com.station.client.proxies.*;

/**
 * Created with IntelliJ IDEA.
 * User: Jimmy87
 * Date: 16.11.13
 * Time: 22:00
 * To change this template use File | Settings | File Templates.
 */
public class DraggableContent {

    private PPlaceableEntity entity;
    public String imgUrl;
    private String name;
    private PCoordinates coordinates;
    private static int pumpsCounter = 0;

    public DraggableContent(String type, String imgUrl,PCoordinates coordinates) {
        this.imgUrl = imgUrl;
        this.coordinates = coordinates;
        if (entity != null)
            entity.pCoordinates = coordinates;
        createEntity(type);
    }

    private void createEntity(String type) {
        name = type;
//        if (type.equals("tank"))
//            entity = new PFuelTank();
        if (type.equals("pump")) {
            entity = new PPetrolPump("A92",coordinates,pumpsCounter);
            PPetrolPump pump = (PPetrolPump)entity;
            pumpsCounter++;
        }
        if (type.equals("office"))
            entity = new PCashOffice(coordinates);
    }
    public String getName() {
        return name;
    }

    public PPlaceableEntity getEntity() {
        return entity;
    }

    public void setEntity(PPlaceableEntity entity) {
        this.entity = entity;
    }

    public void setCoordinates(PCoordinates coordinates) {
        this.coordinates = coordinates;
        if (entity != null)
            entity.pCoordinates = coordinates;
    }

    public PCoordinates getCoordinates() {
        return coordinates;
    }

    public Class getEntityClass() {
        if (entity != null)
            return entity.getClass();
        return null;
    }
}
